package com.lagou.controller;

import com.lagou.pojo.Resume;
import com.lagou.service.IResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class ResumeController {

    @Autowired
    private IResumeService resumeService;

    @RequestMapping("/find")
    public ModelAndView findAll(){
        ModelAndView mv = new ModelAndView();
        mv.setViewName("success");
        mv.addObject("list", resumeService.findAll());
        return mv;
    }


    @RequestMapping("/update")
    public ModelAndView update(Resume resume, ModelAndView mv){
        //做更新操作
        resumeService.update(resume);
        mv.setViewName("success");
        mv.addObject("list", resumeService.findAll());
        //重新做查询并返回前端
        return mv;
    }

    @RequestMapping("/delete")
    public ModelAndView delete(long id, ModelAndView mv){
        resumeService.delete(id);
        mv.setViewName("success");
        mv.addObject("list",resumeService.findAll());
        return mv;
    }

    @RequestMapping("add")
    public ModelAndView add(){
        ModelAndView mv = new ModelAndView();
        mv.setViewName("add");
        return mv;


    }

}
